home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / clipper / clipwndw.zip / CWINDOW.PRG < prev    next >
Text File  |  1990-05-08  |  20KB  |  604 lines

  1. ***********************************************************************
  2. * These are a group of functions that I wrote for Clipper.  They
  3. * enable me to use a very SIMPLE windowing system to approach the
  4. * user. I am letting anyone use this, just mention me in your program.
  5. * I should warn you that the following code is pure Clipper and needs to
  6. * be extended. 
  7. *
  8. * Use, enhance and develop, then buy a good 'C' compiler and do
  9. * your databasing in that. spelled 'see code base 4'.
  10. * You can define GOOD.
  11. *
  12. *
  13. * If you need help or just have a question you can contact me at
  14. *
  15. * Robert Innes
  16. * (701) 293-8739            Home after 6
  17. * innes @ plains            internet address
  18. * rinnes @ extnet.plains.edu
  19. *
  20. *
  21. * If I am not there. 
  22. * Please note the date and remember people do move on. ENJOY !!
  23. ***************************************************************************
  24.  
  25.  
  26.  
  27. *:**********************************************************************:
  28. *:        Program: CWINDOW.PRG
  29. *:
  30. *:         System: Window Library for Clipper
  31. *:         Author: Robert Innes
  32. *:  Last modified: 06/08/89     10:12
  33. *:
  34. *:  Procs & Fncts: WCOLOR()        -       set the colors for a window
  35. *:               : MAKE_WINDOW()   -       build and show a window
  36. *:               : WTITLE()        -       title a window
  37. *:               : WSAYAT()        -       put a string, with clipping in a window
  38. *:               : WMENU()         -       display a windowed' achoice
  39. *:               : REMOVE_WINDOW() -       delete a window, restore if needed
  40. *:               : HOME_CURSOR     -       set the cursor to home
  41. *:               : WTRUNC_STR()    -       internal string truncation
  42. *:               : INRANGE()       -       see if coords are valid internal
  43. *:               : WGOTOXY         -       got to a point in a window
  44. *:               : WMESSAGE        -       pop up a message, various levels
  45. *:
  46. *:*********************************************************************
  47. *               Window Library For Clipper
  48. *
  49. *    DECLARE a Public STRING ARRAY
  50. *
  51. *    window[1] - Top of Window
  52. *    window[2] - Left of Window
  53. *    window[3] - Bottom of Window
  54. *    window[4] - Right of Window
  55. *    window[5] - ForeGround Color of Window
  56. *    window[6] - Background Color of Window
  57. *    window[7] - Title of Window
  58. *    window[8] - Does it Have a Shadow ?
  59. *    window[9] - Current Row of Cursor
  60. *    window[10]- Current Column of Cursor
  61. *    window[11]- Old Row of Cursor
  62. *    window[12]- Old Column of Cursor
  63. *    window[13]- Save contents under window ?
  64. *    window[14] - Window Save Buffer
  65. *
  66.  
  67.  
  68.  
  69. *
  70. *       Public Defines for window Routines
  71. *
  72. * YES, virginia, you need these.  
  73. *
  74.  
  75. PUBLIC shadow, noshadow, shadow_color, saveit, notsave, choic
  76. shadow =  1
  77. noshadow = 0
  78. shadow_color = '+/W'
  79. saveit = 1                                       
  80. notsave = 0
  81.  
  82. *
  83. * Currently all windows have double borders 'cause I was to lazy
  84. * to do any others.
  85. *
  86.  
  87. DOUBLE = CHR(201) + CHR(205) + CHR(187) + CHR(186) + CHR(188) + CHR(205) +;
  88. CHR(200) + CHR(186) + CHR(32)
  89.  
  90. ******************************************************
  91. * The following code is the test procedure. This can
  92. * be taken out when you get the hang of it.
  93. *
  94. * or use the preprocessor you have when you bought
  95. * that GOOD 'C' compiler. ;-)
  96. ******************************************************
  97.  
  98.  
  99.  
  100. PUBLIC win1[14], menu1[20], menuv[20]            && DEFINE PUBLIC VARIABLES
  101.  
  102. menu1[1] = 'Number 1'                            && wpop menu
  103. menu1[2] = 'Number 2'                            && wpop menu
  104. menu1[3] = 'Number 3'                            && wpop menu
  105. menu1[4] = 'Number 4'                            && wpop menu
  106. menu1[5] = 'Number 5'                            && wpop menu
  107. menu1[6] = 'Number 6'                            && wpop menu
  108. menu1[7] = 'Number 7'                            && wpop menu
  109. menu1[8] = 'Number 8'                            && wpop menu
  110. menu1[9] = 'Number 9'                            && wpop menu
  111. menu1[10] = 'Number 10'                          && wpop menu
  112. menu1[11] = 'Number 11'                          && wpop menu
  113. menu1[12] = 'Number 12'                          && wpop menu
  114. menu1[13] = 'Number 13'                          && wpop menu
  115. menu1[14] = 'Number 14'                          && wpop menu
  116. menu1[15] = 'Number 15'                          && wpop menu
  117. menu1[16] = 'Number 16'                          && wpop menu
  118. menu1[17] = 'Number 17'                          && wpop menu
  119. menu1[18] = 'Number 18'                          && wpop menu
  120. menu1[19] = 'Number 19'                          && wpop menu
  121. menu1[20] = 'Number 20'                          && wpop menu
  122.  
  123. *
  124. *  If an option is set to false then it is displayed but not 
  125. *  selectable. See achoice in the clipper manual.
  126. *
  127.  
  128. menuv[1] = .T.                                   && wpop menu
  129. menuv[2] = .T.                                   && wpop menu
  130. menuv[3] = .T.                                   && wpop menu
  131. menuv[4] = .T.                                   && wpop menu
  132. menuv[5] = .F.                                   && wpop menu
  133. menuv[6] = .T.                                   && wpop menu
  134. menuv[7] = .F.                                   && wpop menu
  135. menuv[8] = .T.                                   && wpop menu
  136. menuv[9] = .T.                                   && wpop menu
  137. menuv[10] = .T.                                  && wpop menu
  138. menuv[11] = .T.                                  && wpop menu
  139. menuv[12] = .T.                                  && wpop menu
  140. menuv[13] = .T.                                  && wpop menu
  141. menuv[14] = .T.                                  && wpop menu
  142. menuv[15] = .T.                                  && wpop menu
  143. menuv[16] = .T.                                  && wpop menu
  144. menuv[17] = .T.                                  && wpop menu
  145. menuv[18] = .T.                                  && wpop menu
  146. menuv[19] = .T.                                  && wpop menu
  147. menuv[20] = .T.                                  && wpop menu
  148.  
  149. win1[1] = STR(5)
  150. win1[2] = STR(5)
  151. win1[3] = STR(20)
  152. win1[4] = STR(40)
  153. win1[8] = STR(shadow)
  154. win1[13]= STR(saveit)
  155. wcolor( win1, 'BG', ' ')
  156. win1[14] = make_window( win1 )
  157. wtitle(win1, 'This is window Number 1')
  158. wsayat( win1, 5, 5, 'A String')
  159. wsayat( win1, 6, 5, 'A Very Very Long String That Should Not Print Far' )
  160.  
  161. wmessage(10, 10, 'Just a Note', 1)
  162. wmessage(10, 10, 'Just a Warning, Improper Input', 2)
  163. wmessage(10, 10, 'Error has Occured', 3)
  164. wmessage(10, 10, 'Everything is OK', 9)
  165.  
  166. choic = wpop_menu( 5, 5, 'Choices', 20, menu1, menuv )
  167. wsayat( win1, 7, 5, 'Choice = ' + LTRIM(STR(choic) ) )
  168. INKEY(0)
  169. remove_window( win1 )
  170.  
  171. RETURN                                           && return to calling program
  172.  
  173. *!*********************************************************************
  174. *!
  175. *!       Function: MAKE_WINDOW()
  176. *!
  177. *!      Called by: CWINDOW.PRG
  178. *!               : WMENU()        (function  in CWINDOW.PRG)
  179. *!               : WMESSAGE       (procedure in CWINDOW.PRG)
  180. *!
  181. *!          Calls: HOME_CURSOR    (procedure in CWINDOW.PRG)
  182. *!
  183. *!*********************************************************************
  184. FUNCTION make_window
  185.    PARAMETERS WINDOW
  186.  
  187.    PRIVATE wtop, wright, wbot, wleft, Buffer, shadow_bot, shadow_right, old_color  && DEFINE PRIVATE VARIABLES
  188.    PRIVATE wcolor                                && DEFINE PRIVATE VARIABLES
  189.    PRIVATE TOP, RIGHT, bot, LEFT                 && DEFINE PRIVATE VARIABLES
  190.  
  191.    *
  192.    *       Convert window values to integer
  193.    *
  194.    TOP = VAL(WINDOW[1])
  195.    LEFT = VAL(WINDOW[2])
  196.    bot = VAL(WINDOW[3])
  197.    RIGHT = VAL(WINDOW[4])
  198.  
  199.  
  200.    *
  201.    *       Set up actual window;  inside minus border
  202.    *
  203.    wtop = VAL(WINDOW[1]) + 1
  204.    wleft = VAL(WINDOW[2]) + 1
  205.    wbot = VAL(WINDOW[3]) - 1
  206.    wright = VAL(WINDOW[4]) - 1
  207.  
  208.    *
  209.    *       Save the Window underneath
  210.    *
  211.    IF VAL(WINDOW[13]) == saveit
  212.       IF VAL(WINDOW[8]) == noshadow
  213.          Buffer = Savescreen( TOP, LEFT, bot, RIGHT )
  214.       ELSE